package com.camp.android.trip.n.track.menu;

import com.camp.android.trip.n.track.DatabaseManager;
import com.camp.android.trip.n.track.R;
import com.camp.android.trip.n.track.Trip;
import com.camp.android.trip.n.track.trip.TripItineraryActivity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.ListFragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

public class MenuCurrentFragment extends ListFragment {

	private CurrentListAdapter adapter = null;
	private Trip currentTrip;
	
    public MenuCurrentFragment(Trip trip) {
    	this.currentTrip = trip;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Log.i("Tag","Created upcoming fragment");
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
    	Log.i("MenuCurrentFragment",""+currentTrip.items.size()); 
    	View rootView;
    	if(currentTrip.items.size() > 0) {
    		
	    	rootView = inflater.inflate(R.layout.fragment_menu_upcoming, container, false);
	        Log.i("MenuCurrentFragment","upcoming fragment view created");
	        adapter = new CurrentListAdapter(inflater,getActivity());
    	}
    	else {
    		rootView = inflater.inflate(R.layout.fragment_menu_upcoming_empty, container, false);
    		
	        Log.i("MenuCurrentFragment","empty fragment view created");
	        //adapter = new CurrentListAdapter(inflater,getActivity());
    	}
    	return rootView;
    }
    
    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
    	super.onActivityCreated(savedInstanceState); 
    	Log.i("TAG","ManuUpcomingFragment onActivityCreated");
    	setListAdapter(adapter);
    }
    
    @Override
    public void onListItemClick(ListView l, View v, int position, long id) {
    	Log.i("TAG","Clicked on pos "+position);
    }
}


